package cn.shengchao.examstar.ai.domain.valueobject;

import lombok.Getter;

import java.util.Objects;

/**
 * 类目类型值对象
 */
@Getter
public class SpecificationType {
    
    private final Long value;
    
    private SpecificationType(Long value) {
        if (value == null || value <= 0) {
            throw new IllegalArgumentException("类目ID必须大于0");
        }
        this.value = value;
    }
    
    /**
     * 创建类目类型
     */
    public static SpecificationType of(Long value) {
        return new SpecificationType(value);
    }
    
    /**
     * 判断是否为有效的类目
     */
    public boolean isValid() {
        return value != null && value > 0;
    }
    
    /**
     * 判断是否与另一个类目相同
     */
    public String getName() {
        // In a real application, this would likely look up the name from a database or configuration.
        return "类目 " + value;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SpecificationType that = (SpecificationType) o;
        return Objects.equals(value, that.value);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
    
    @Override
    public String toString() {
        return "类目[" + value + "]";
    }
}